 package tls;

import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;

/**
 * 查询自己当前程序默认支持的SSL/TSL版本的方法
 * @author microdsyKoal
 * @date 2018/10/12
 */
public class TLSTest {
    public static void main(String[] args) throws Exception {
    		SSLContext context = SSLContext.getInstance("TLS");
    		context.init(null, null, null);
     
    		SSLSocketFactory factory = (SSLSocketFactory) context.getSocketFactory();
    		SSLSocket socket = (SSLSocket) factory.createSocket();
     
    		String[] protocols = socket.getSupportedProtocols();
     
    		System.out.println("Supported Protocols: " + protocols.length);
    		for (int i = 0; i < protocols.length; i++) {
    			System.out.println(" " + protocols[i]);
    		}
     
    		protocols = socket.getEnabledProtocols();
     
    		System.out.println("Enabled Protocols: " + protocols.length);
    		for (int i = 0; i < protocols.length; i++) {
    			System.out.println(" " + protocols[i]);
    		}
     
    	}
    
}

 